<!-- 翻译配置 -->
<template>
    <div>
        <el-card class="!border-none" shadow="never" v-loading="state.loading">
            <el-table size="large" :data="state.lists">
                <el-table-column :label="$t('翻译平台')" prop="name" min-width="120" />
                <el-table-column :label="$t('状态')" min-width="120">
                    <template #default="{ row }">
                        <el-tag :type="row.status !== 1 ? 'danger' : ''">{{ row.status !== 1 ? $t('关闭') : $t('开启')
                        }}</el-tag>
                    </template>
                </el-table-column>
                <el-table-column :label="$t('操作')" min-width="120" fixed="right">
                    <template #default="{ row }">
                        <el-button v-perms="['setting/lang/config/setConfig']" type="primary" link
                            @click="handleSet(row.type)">
                            {{ $t('设置') }}
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>
        <edit-popup ref="editRef" @success="getLists" />
    </div>
</template>

<script lang="ts" setup name="config">
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
import { getTranslateLists } from '@/api/setting/lang'
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()

// 列表数据
const state = reactive({
    loading: false,
    lists: []
})

// 获取存储引擎列表数据
const getLists = async () => {
    try {
        state.loading = true
        state.lists = await getTranslateLists()
        state.loading = false
    } catch (error) {
        state.loading = false
    }
}

const handleSet = (alias: string) => {
    editRef.value?.open(alias)
}

getLists()
</script>

<style lang="scss" scoped></style>
